package com.le.tester.book.effectivejava3rdchinese.secondReading.l37;

/**
 * createTime：2024-09-18 14:08
 * description：不要这么做
 */
public enum Phase {

    SOLID, LIQUID, GAS;

    public enum Transition {
        MELT, FREEZE, BOIL, CONDENSE, SUBLIME, DEPOSIT;

        //使用二维数组来映射键值对，是错误的示范
        private static final Transition[][] TRANSITIONS = {
                {null, MELT, SUBLIME},
                {FREEZE, null, BOIL},
                {DEPOSIT, CONDENSE, null}
        };

        public static Transition from(Phase from, Phase to) {
            return TRANSITIONS[from.ordinal()][to.ordinal()];
        }
    }
}
